

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using JTC.MiniCommerce.Core;
using JTC.MiniCommerce.Localization;
using JTC.MiniCommerce.Store.Web.Controls;
using SubSonic.Utilities;

namespace JTC.MiniCommerce.Web.admin.controls.navigation {
  public partial class order : AdminControl {
  
    #region Member Variables
  
    private int orderId = 0;
    private string view = string.Empty;
    
    #endregion
    
    #region Page Events

    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e) {
      try {
        orderId = Utility.GetIntParameter("orderId");
        view = Utility.GetParameter("view");
        orderMenu.MenuItemDataBound += new MenuEventHandler(orderMenu_MenuItemDataBound);
        orderMenu.DataBound += new EventHandler(orderMenu_DataBound);
      }
      catch(Exception ex) {
        Logger.Error(typeof(order).Name + ".Page_Load", ex);
        MasterPage.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(ex.Message));
      }
    }

    /// <summary>
    /// Handles the DataBound event of the orderMenu control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
    void orderMenu_DataBound(object sender, EventArgs e) {
      switch(view) {
        case "r":
          orderMenu.Items[0].Selected = true;
          break;
        case "t":
          orderMenu.Items[0].ChildItems[0].Selected = true;
          break;
        case "a":
          orderMenu.Items[0].ChildItems[1].Selected = true;
          break;
        case "s":
          orderMenu.Items[0].ChildItems[2].Selected = true;
          break;
        case "n":
          orderMenu.Items[0].ChildItems[3].Selected = true;
          break;
        default:
          orderMenu.Items[0].Selected = true;
          break;
      }
    }

    /// <summary>
    /// Handles the MenuItemDataBound event of the orderMenu control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="T:System.Web.UI.WebControls.MenuEventArgs"/> instance containing the event data.</param>
    void orderMenu_MenuItemDataBound(object sender, MenuEventArgs e) {
      e.Item.NavigateUrl = e.Item.NavigateUrl + string.Format("&orderId={0}", orderId);
    }
    
    #endregion
    
  }
}